package org.thanos.demo.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.thanos.demo.entity.Demo;

import java.util.UUID;

@Component
public class DemoTask {

    @Autowired
    private ApplicationEventPublisher publisher;

    @Scheduled(fixedDelay = 1000)
    @Async
    public void demo() {
        publisher.publishEvent(new Demo(UUID.randomUUID().toString()));
    }
}
